package com.owen.mybatis.listener;

import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.owen.mybatis.entity.Aaa;
import com.owen.mybatis.mapper.AaaMapper;
import org.springframework.beans.factory.annotation.Autowired;

public class AaaListener extends AnalysisEventListener<Aaa> {

    @Autowired
    private AaaMapper aaaMapper;

    public AaaListener(AaaMapper aaaMapper) {
        this.aaaMapper = aaaMapper;
    }

    @Override
    public void invoke(Aaa aaa, AnalysisContext analysisContext) {
        aaa.setId(IdWorker.getId());
        aaaMapper.insert(aaa);
    }

    @Override
    public void doAfterAllAnalysed(AnalysisContext analysisContext) {

    }
}
